package graphics.screens;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;

import playlist.Crawler;

import function.Mp3File;
import graphics.SearchChoiceInput;

public class NewListScreen extends Canvas implements CommandListener {
	
	private final Command cancelCommand = new Command("Cancel",
			Command.EXIT, 1);
	
	SearchChoiceInput mp3ListDisplay;
	
	public NewListScreen(Mp3File[] mp3s) {
		mp3ListDisplay =new SearchChoiceInput(mp3s);
		mp3ListDisplay.gotoLastPage();
	}

	protected void paint(Graphics graphics) {
		addCommand(cancelCommand);
		setCommandListener(this);
		mp3ListDisplay.repaint(graphics);
	}

	public void keyPressed(int keyCode) {
		mp3ListDisplay.processKey(keyCode);
		repaint();
	}

	public void commandAction(Command command, Displayable dis) {
		if (command == cancelCommand) {
			Crawler.getInstance().cancelNewList();
		} 
	}
}
